package utilidades;


import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.converters.basic.DateConverter;
import com.thoughtworks.xstream.io.xml.DomDriver;

import entities.Rodamiento;

public class XMLParserRodamiento {

	private static XMLParserRodamiento instance;
	
	private XStream xStream;
	
	private XMLParserRodamiento() {
            xStream = new XStream(new DomDriver());
            xStream.alias("Rodamiento", Rodamiento.class);
            xStream.omitField(Rodamiento.class, "listaMateriasPrima");
            xStream.omitField(Rodamiento.class, "precio");
            xStream.omitField(Rodamiento.class, "proveedor");
            xStream.omitField(Rodamiento.class, "medida");
            xStream.addDefaultImplementation(java.sql.Date.class,java.util.Date.class); 
            xStream.addDefaultImplementation(java.sql.Timestamp.class,java.util.Date.class); 
            xStream.addDefaultImplementation(java.sql.Time.class,java.util.Date.class); 
            xStream.registerConverter(new DateConverter("yyyyMMdd",new String[12]));
    }
	
	
	public static XMLParserRodamiento obtenerInstanciaXMLRodamiento(){
		if(instance== null){
			instance = new XMLParserRodamiento();
		}
		return instance;
	}
	
	public synchronized String parsear(Object object){
		return xStream.toXML(object);
	}
}
